<template>
    <div class="find-container">
        <div class="form">
            <span class="form_title">创建全新的企业/组织</span>
            <el-form ref="form" :model="sizeForm" label-width="auto" label-position="top">
                <el-form-item label="你的姓名">
                    <el-input v-model="sizeForm.legalUserName" />
                </el-form-item>
                <el-form-item label="企业或组织名称">
                    <el-input v-model="sizeForm.name" />
                </el-form-item>
            </el-form>
            
            <div class="form_button">
                <el-button type="primary" @click="onSubmit">完 成</el-button>
                    <el-button @click="closeForm">跳 过</el-button>
            </div>
        </div>
    </div>
</template>
  
<script>
import { reactive, toRefs, onMounted, ref, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { useRouter } from 'vue-router'
import api from '/@/api/commonApi'
export default {
    name: 'Inint',
    components: {
    },
    setup() {
        const state = reactive({
            sizeForm: {}
        })
        const router = useRouter()
        const closeForm =()=>{
            router.push({
                    path: '/home'
                })
        }

        const onSubmit =()=>{
            api.enterpriseInfoEdit(state.sizeForm).then(res=>{
                if(res.code == 0){
                    ElMessage({ 
                        type: 'success', 
                        message: '创建成功',
                        onClose:()=>{
                            closeForm ()
                        }
                     })
                }
            })
        }
        
        onMounted(  () => {
         api.enterpriseInfo().then(res=>{
            res.data.name = null
            state.sizeForm = res.data
         });

        })
        return {
            onSubmit,
            closeForm,
            ...toRefs(state)
        }
    }
}
</script>
  
<style lang="scss" scoped>
.find-container {

    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    margin-top: 10%;

    .form {
        width: 500px;
        height: 500px;
    }
    .form_title{
        width: 100%;
        height: 25px;
        font-size: 25px;
        font-weight: bold;
        margin-bottom: 50px;
    }
    .form_button{
        margin-top: 50px;
        text-align: center;
    }
}
</style>